<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS过渡效果示例</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            padding: 2rem;
            background-color: #f0f0f0;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
        }

        h1 {
            text-align: center;
            margin-bottom: 2rem;
            color: #333;
        }

        .example-section {
            background: white;
            padding: 2rem;
            margin-bottom: 2rem;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        h2 {
            margin-bottom: 1rem;
            color: #444;
        }

        /* 1. 基础过渡效果 */
        .hover-button {
            padding: 10px 20px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .hover-button:hover {
            background-color: #0056b3;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }

        /* 2. 多属性过渡 */
        .card {
            width: 200px;
            height: 120px;
            background-color: #fff;
            border-radius: 8px;
            padding: 1rem;
            margin: 1rem 0;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            transition: transform 0.3s ease,
                        box-shadow 0.3s ease-in-out,
                        background-color 0.3s linear;
        }

        .card:hover {
            transform: scale(1.05);
            box-shadow: 0 8px 16px rgba(0,0,0,0.2);
            background-color: #f8f9fa;
        }

        /* 3. 延迟过渡 */
        .menu-item {
            padding: 10px 20px;
            background: #6c757d;
            color: white;
            margin: 5px;
            border-radius: 4px;
            transition: transform 0.3s ease var(--delay),
                        background-color 0.3s ease;
        }

        .menu-container:hover .menu-item {
            background-color: #5a6268;
        }

        .menu-container:hover .menu-item:hover {
            transform: translateX(10px);
            background-color: #495057;
        }

        .menu-item:nth-child(1) { --delay: 0s; }
        .menu-item:nth-child(2) { --delay: 0.1s; }
        .menu-item:nth-child(3) { --delay: 0.2s; }

        /* 4. 自定义timing function */
        .bounce-button {
            padding: 10px 20px;
            background-color: #28a745;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: transform 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        }

        .bounce-button:hover {
            transform: scale(1.1);
        }

        /* 5. 渐变过渡 */
        .gradient-button {
            padding: 10px 20px;
            background: linear-gradient(45deg, #ff6b6b, #ff8e53);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            background-size: 200% 200%;
            background-position: 0% 0%;
            transition: background-position 0.6s ease;
        }

        .gradient-button:hover {
            background-position: 100% 100%;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>CSS过渡效果示例</h1>

        <div class="example-section">
            <h2>1. 基础过渡效果</h2>
            <p>简单的悬停效果，包含背景色变化和位移：</p>
            <button class="hover-button">悬停我</button>
        </div>

        <div class="example-section">
            <h2>2. 多属性过渡</h2>
            <p>同时过渡多个属性，每个属性可以有不同的时间和缓动函数：</p>
            <div class="card">
                多属性过渡卡片
            </div>
        </div>

        <div class="example-section">
            <h2>3. 延迟过渡</h2>
            <p>使用延迟创建序列动画效果：</p>
            <div class="menu-container">
                <div class="menu-item">菜单项 1</div>
                <div class="menu-item">菜单项 2</div>
                <div class="menu-item">菜单项 3</div>
            </div>
        </div>

        <div class="example-section">
            <h2>4. 自定义timing function</h2>
            <p>使用cubic-bezier创建自定义的缓动效果：</p>
            <button class="bounce-button">弹跳按钮</button>
        </div>

        <div class="example-section">
            <h2>5. 渐变过渡</h2>
            <p>使用background-position创建渐变过渡效果：</p>
            <button class="gradient-button">渐变按钮</button>
        </div>
    </div>
</body>
</html>
